package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhStoreOrderRel;
import com.ruoyi.zsyh.service.IZsyhStoreOrderRelService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大区会长预订单详细Controller
 * 
 * @author yuexl
 * @date 2022-03-02
 */
@Controller
@RequestMapping("/zsyh/storeOrderRel")
public class ZsyhStoreOrderRelController extends BaseController
{
    private String prefix = "zsyh/storeOrderRel";

    @Autowired
    private IZsyhStoreOrderRelService zsyhStoreOrderRelService;

    @RequiresPermissions("zsyh:storeOrderRel:view")
    @GetMapping()
    public String storeOrderRel()
    {
        return prefix + "/storeOrderRel";
    }

    /**
     * 查询大区会长预订单详细列表
     */
    @RequiresPermissions("zsyh:storeOrderRel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhStoreOrderRel zsyhStoreOrderRel)
    {
        startPage();
        List<ZsyhStoreOrderRel> list = zsyhStoreOrderRelService.selectZsyhStoreOrderRelList(zsyhStoreOrderRel);
        return getDataTable(list);
    }

    /**
     * 导出大区会长预订单详细列表
     */
    @RequiresPermissions("zsyh:storeOrderRel:export")
    @Log(title = "大区会长预订单详细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhStoreOrderRel zsyhStoreOrderRel)
    {
        List<ZsyhStoreOrderRel> list = zsyhStoreOrderRelService.selectZsyhStoreOrderRelList(zsyhStoreOrderRel);
        ExcelUtil<ZsyhStoreOrderRel> util = new ExcelUtil<ZsyhStoreOrderRel>(ZsyhStoreOrderRel.class);
        return util.exportExcel(list, "大区会长预订单详细数据");
    }

    /**
     * 新增大区会长预订单详细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存大区会长预订单详细
     */
    @RequiresPermissions("zsyh:storeOrderRel:add")
    @Log(title = "大区会长预订单详细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhStoreOrderRel zsyhStoreOrderRel)
    {
        return toAjax(zsyhStoreOrderRelService.insertZsyhStoreOrderRel(zsyhStoreOrderRel));
    }

    /**
     * 修改大区会长预订单详细
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhStoreOrderRel zsyhStoreOrderRel = zsyhStoreOrderRelService.selectZsyhStoreOrderRelById(id);
        mmap.put("zsyhStoreOrderRel", zsyhStoreOrderRel);
        return prefix + "/edit";
    }

    /**
     * 修改保存大区会长预订单详细
     */
    @RequiresPermissions("zsyh:storeOrderRel:edit")
    @Log(title = "大区会长预订单详细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhStoreOrderRel zsyhStoreOrderRel)
    {
        return toAjax(zsyhStoreOrderRelService.updateZsyhStoreOrderRel(zsyhStoreOrderRel));
    }

    /**
     * 删除大区会长预订单详细
     */
    @RequiresPermissions("zsyh:storeOrderRel:remove")
    @Log(title = "大区会长预订单详细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhStoreOrderRelService.deleteZsyhStoreOrderRelByIds(ids));
    }
}
